﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace whuc.PlaneGame
{
    /// <summary>
    /// 玩家飞机的对象
    /// </summary>
    public class Hero:GameObject
    {
       
        public bool IsTowBullet { get; set; }   //飞机是否是双排子弹

        public Hero(int x,int y):base(x,y,Properties.Resources.hero3)
        {
            this.IsTowBullet = false;     //默认情况下，它不是双排子弹
            this.Width = this.img.Width / 2;
            this.Height = this.img.Height / 2;
        }


        /// <summary>
        /// 玩家飞机发射子弹的方式
        /// </summary>
        public void Fire()
        {
            if (this.IsTowBullet)
            {
                //说明要发双排子弹
                Bullet b_left = new Bullet(this.X, this.Y);
                Bullet b_right = new Bullet(this.X, this.Y);
                //修正左边子弹的位置
                b_left.X = b_left.X + this.Width / 4 - b_left.Width / 2;

                //修正右边子弹的位置
                b_right.X = b_right.X + this.Width / 4 * 3 - b_right.Width / 2;

                DataUtil.bulletList.Add(b_left);
                DataUtil.bulletList.Add(b_right);
            }
            else
            {
                //玩家飞机发射的子弹是有很多个的
                Bullet b = new Bullet(this.X, this.Y);
                //修正子弹的坐标
                b.X = b.X + this.Width / 2 - b.Width / 2;

                //用集全去装所有的玩家飞机子弹
                DataUtil.bulletList.Add(b);
            }
        }

    }
}
